package data;

import java.util.Observable;

/**
 * Working Mode class is a singleton class which is used to decide in which mode
 * the application is working. Currently, there are three mode supported: Local,
 * Server, Client It extends the Observable interface, when the working mode has
 * been changed it will notify the observers to change the ui.
 * 
 * @author Jie Zhao(288654)
 * 
 */
public final class WorkingMode extends Observable {
	private static MODE workingMode = null;
	private static WorkingMode instance = null;

	private WorkingMode() {
	}

	public static WorkingMode getInstance() {
		if (instance == null) {
			instance = new WorkingMode();
		}
		return instance;
	}

	public enum MODE {
		LOCAL, CLIENT, SERVER
	}

	public void changeWorkingMode(MODE mode) {
		if (workingMode != mode) {
			workingMode = mode;
			setChanged();
			notifyObservers();
		}
	}

	public MODE getWorkingMode() {
		return workingMode;
	}
}
